package round79;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * User: Samuel
 * Date: 08-03-11
 * Time: 02:33 PM
 */
public class A {
    public static void main(String[] args) throws IOException {
        new A().run();
    }

    private void run() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String split[] = in.readLine().split(" ");
        int n = Integer.parseInt(split[0]);
        int m = Integer.parseInt(split[1]);
        int prices[] = new int[n];
        split = in.readLine().split(" ");
        for (int i = 0; i < prices.length; i++) {
            prices[i] = Integer.parseInt(split[i]);
        }
        List<String> pairs = new ArrayList<String>();
        int a, b;
        for (int i = 0; i < m; i++) {
            split = in.readLine().split(" ");
            a = Integer.parseInt(split[0]);
            b = Integer.parseInt(split[1]);
            pairs.add(getPair(a, b));
        }
        Collections.sort(pairs);
        int min = Integer.MAX_VALUE;
        for (int i = 1; i <= n; i++) {
            for (int j = i+1; j <= n; j++) {
//                if(i == j) continue;
                for (int k = j+1; k <= n; k++) {
//                    if(k == i || k == j) continue;
                    if (Collections.binarySearch(pairs, i + " " + j) < 0 || Collections.binarySearch(pairs, j + " " + k) < 0 || Collections.binarySearch(pairs, i + " " + k) < 0) {
                        continue;
                    }
                    int p = prices[i - 1] + prices[j - 1] + prices[k - 1];
                    if (p < min) {
                        min = p;
                    }
                }
            }
        }
        if (min == Integer.MAX_VALUE) {
            System.out.println(-1);
        } else {
            System.out.println(min);
        }
    }

    private String getPair(int a, int b) {
        if (a < b) {
            return a + " " + b;
        } else {
            return b + " " + a;
        }
    }
}
